﻿using DevExpress.ExpressApp;
using EasyXaf.EntityDesigner.BusinessObjects.Entities;

namespace EasyXaf.EntityDesigner.Editors.EntityAssociationEditors;

public class EntityAssociationModel
{
    public IObjectSpace ObjectSpace { get; set; }

    public Guid DomainModelId { get; set; }

    public double[] ViewportBounds { get; set; }

    public event EventHandler RefreshRequested;

    public event EventHandler UnselectAllRequested;

    public event EventHandler<EntityDoubleClickedEventArgs> EntityDoubleClicked;

    public event EventHandler<SelectionChangedEventArgs> SelectionChanged;

    public event EventHandler<QueryCollectionSourceEventArgs> QueryCollectionSource;

    public void Refresh()
    {
        RefreshRequested?.Invoke(this, EventArgs.Empty);
    }

    public void UnselectAll()
    {
        UnselectAllRequested?.Invoke(this, EventArgs.Empty);
    }

    public void RaiseEntityDoubleClicked(Entity entity)
    {
        EntityDoubleClicked?.Invoke(this, new EntityDoubleClickedEventArgs(entity));
    }

    public void RaiseSelectionChanged(IEnumerable<Entity> selectedEntities)
    {
        SelectionChanged?.Invoke(this, new SelectionChangedEventArgs(selectedEntities));
    }

    public void RaiseQueryCollectionSource(QueryCollectionSourceEventArgs args)
    {
        QueryCollectionSource?.Invoke(this, args);
    }
}
